package io.github.mayubao.kotlintest

import org.junit.Assert
import org.junit.Assert.*
import org.junit.Test

class Day10_DataClassTest{

    @Test
    fun testDataClass(){
        val user = User("mayubao", 25)
//        assertEquals(vval, "test")
        assertNotNull(user)
    }

    @Test
    fun testDataClassToString(){
        val user = User("mayubao", 25)
//        assertEquals(user.name, user.copy().name)
        assertNotEquals(user.name, user.copy(name="ma").name)
    }


//    QA:
    //1.how to define the data class
        //data class is one of the classese type, and the class is only include the data
    //2. what the feature of the data class

    data class User(val name: String , val age :Int){
        override fun equals(other: Any?): Boolean {
            println("User --->>>equals")
            return super.equals(other)
        }

        override fun hashCode(): Int {
            println("User --->>>hashCode")
            return super.hashCode()
        }

        override fun toString(): String {
            println("User --->>>toString" + super.toString())
            return super.toString()
        }
    }

}